From 601a4a15ef41acab383769b4c6cf8001dae7bccf Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 28 Feb 2008 10:48:42 +0000 Subject: [PATCH] kexec: extend hypercall for efi memory map, boot parameter and xenheap regions Extend the kexec hypercall to allow it to return the efi memory map, boot parameter and xen heap regions. The efi memory map and boot parameter regions need to be supplied by xen to dom0, rather than established by dom0 as dom0's memory is not machine memory and thus the regions are not in the correct location. These regions are inserted into machine_iomem by dom0. The xen heap region is needed as on xen the hypervisor code and heap exist in two different EFI memory regions, which are reflected in machine_iomem. Thus a single xen code region can't be inserted into machine_iomem. Signed-off-by: Simon Horman --- xen/arch/ia64/xen/machine_kexec.c | 42 ++++++++++++++++++++++++++++--- xen/include/public/kexec.h | 15 ++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/xen/arch/ia64/xen/machine_kexec.c b/xen/arch/ia64/xen/machine_kexec.c index 58590b7c39..d1addea8c1 100644 --- a/xen/arch/ia64/xen/machine_kexec.c +++ b/xen/arch/ia64/xen/machine_kexec.c @@ -24,6 +24,7 @@ #include #include #include +#include typedef asmlinkage NORET_TYPE void (*relocate_new_kernel_t)( unsigned long indirection_page, @@ -167,17 +168,50 @@ void machine_reboot_kexec(xen_kexec_image_t *image) static int machine_kexec_get_xen(xen_kexec_range_t *range) { - range->start = virt_to_maddr(_start); + range->start = range->start = ia64_tpa(_text); + range->size = (unsigned long)_end - (unsigned long)_text; + return 0; +} + +#define ELF_PAGE_SHIFT 16 +#define ELF_PAGE_SIZE (__IA64_UL_CONST(1) << ELF_PAGE_SHIFT) +#define ELF_PAGE_MASK (~(ELF_PAGE_SIZE - 1)) + +static int machine_kexec_get_xenheap(xen_kexec_range_t *range) +{ + range->start = (ia64_tpa(_end) + (ELF_PAGE_SIZE - 1)) & ELF_PAGE_MASK; range->size = (unsigned long)xenheap_phys_end - (unsigned long)range->start; return 0; } +static int machine_kexec_get_boot_param(xen_kexec_range_t *range) +{ + range->start = __pa(ia64_boot_param); + range->size = sizeof(*ia64_boot_param); + return 0; +} + +static int machine_kexec_get_efi_memmap(xen_kexec_range_t *range) +{ + range->start = ia64_boot_param->efi_memmap; + range->size = ia64_boot_param->efi_memmap_size; + return 0; +} + int machine_kexec_get(xen_kexec_range_t *range) { - if (range->range != KEXEC_RANGE_MA_XEN) - return -EINVAL; - return machine_kexec_get_xen(range); + switch (range->range) { + case KEXEC_RANGE_MA_XEN: + return machine_kexec_get_xen(range); + case KEXEC_RANGE_MA_XENHEAP: + return machine_kexec_get_xenheap(range); + case KEXEC_RANGE_MA_BOOT_PARAM: + return machine_kexec_get_boot_param(range); + case KEXEC_RANGE_MA_EFI_MEMMAP: + return machine_kexec_get_efi_memmap(range); + } + return -EINVAL; } /* diff --git a/xen/include/public/kexec.h b/xen/include/public/kexec.h index bb0ca142dd..fbad3606ac 100644 --- a/xen/include/public/kexec.h +++ b/xen/include/public/kexec.h @@ -126,9 +126,18 @@ typedef struct xen_kexec_load { xen_kexec_image_t image; } xen_kexec_load_t; -#define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */ -#define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */ -#define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */ +#define KEXEC_RANGE_MA_CRASH 0 /* machine address and size of crash area */ +#define KEXEC_RANGE_MA_XEN 1 /* machine address and size of Xen itself */ +#define KEXEC_RANGE_MA_CPU 2 /* machine address and size of a CPU note */ +#define KEXEC_RANGE_MA_XENHEAP 3 /* machine address and size of xenheap + * Note that although this is adjacent + * to Xen it exists in a separate EFI + * region on ia64, and thus needs to be + * inserted into iomem_machine separately */ +#define KEXEC_RANGE_MA_BOOT_PARAM 4 /* machine address and size of + * the ia64_boot_param */ +#define KEXEC_RANGE_MA_EFI_MEMMAP 5 /* machine address and size of + * of the EFI Memory Map */ /* * Find the address and size of certain memory areas -- 2.30.2